/* 布局 */
import Layout from '@/layout'

// 路由定义（即所有可能的路由，定义在此）
const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '仪表盘', icon: 'dashboard' }
    }]
  },

  {
    path: '/shopping',
    component: Layout,
    redirect: '/shopping/product',
    name: 'shopping',
    meta: { title: '商城', icon: 'el-icon-s-help', access: ['shopping'] },
    children: [
      {
        path: 'product',
        name: 'product',
        component: () => import('@/views/shopping/product/index'),
        meta: { title: '商品', icon: 'table', access: ['product'] }
      },
      {
        path: 'tree01',
        name: 'Tree01',
        component: () => import('@/views/tree/index'),
        meta: { title: 'Tree', icon: 'tree', access: ['Tree01'] }
      }
    ]
  },

  {
    path: '/cms',
    component: Layout,
    redirect: '/cms/article',
    name: 'cms',
    meta: { title: '内容管理', icon: 'el-icon-s-help', access: ['cms'] },
    children: [
      {
        path: 'article',
        name: 'article',
        component: () => import('@/views/cms/article/index'),
        meta: { title: '文章', icon: 'table', access: ['article'] }
      },
      {
        path: 'category',
        name: 'category',
        component: () => import('@/views/cms/category/index'),
        meta: { title: '文章分类', icon: 'tree', access: ['category'] }
      }
    ]
  },

  {
    path: '/setting',
    component: Layout,
    redirect: '/setting/roles',
    name: 'setting',
    meta: { title: '系统设置', icon: 'el-icon-s-help', access: ['setting'] },
    children: [
      {
        path: 'roles',
        name: 'roles',
        component: () => import('@/views/setting/roles/index'),
        meta: { title: '角色设置', icon: 'table', access: ['roles'] }
      },
      {
        path: 'users',
        name: 'users',
        component: () => import('@/views/setting/users/index'),
        meta: { title: '用户设置', icon: 'tree', access: ['users'] }
      }
    ]
  },
  {
    path: '/404',
    name: 'error_404',
    component: () => import('@/views/error/404'),
    hidden: true
  },

  {
    path: '/401',
    name: 'error_401',
    component: () => import('@/views/error/401'),
    hidden: true
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

export default routes
